package DAO;

import Interfaces.IPrintStores_Dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.proteanit.sql.DbUtils;

public class Personal_Dao implements IPrintStores_Dao {

    @Override
    public void printStores() throws IllegalArgumentException {
        Connection conn = null;
        ResultSet rs = null;
        PreparedStatement pst = null;
        try {
            conn = javaconnect.connectDB();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Personal_Dao.class.getName()).log(Level.SEVERE, null, ex);
        }

        String query = "SELECT storeName , city , seats , daysopen FROM stores";
        try {
            pst = conn.prepareStatement(query);
            rs = pst.executeQuery();
            Frames.Personal_Frame.searchTable.setModel(DbUtils.resultSetToTableModel(rs));

            pst.close();
            conn.close();
            rs.close();

        } catch (SQLException e) {
            throw new IllegalArgumentException("Error in PrintStores_Dao ");
        }
    }

}
